package com.yanxi.controller;


import com.yanxi.pojo.Emp;
import com.yanxi.pojo.LoginInfo;
import com.yanxi.pojo.Result;
import com.yanxi.service.EmpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录控制器
 * @author tera
 *
 */
@RequestMapping("/login")
@RestController
public class LoginController {
    public static final Logger log = LoggerFactory.getLogger(LoginController .class);


    @Autowired
    private EmpService empService;
   @PostMapping
    public Result login(@RequestBody  Emp emp){
        log.info ("员工登录，员工信息：{}",emp);
        LoginInfo loginInfo =empService.login(emp);
        if (loginInfo != null){
            return Result.success(loginInfo);
        }
        return Result.error("用户名或密码错误");
    }
}
